<?php
class User extends AppModel {
  var $name = 'User';
  var $primaryKey = 'id';
  
  //TODO - error messages
  var $validate = array(
    'username' => array(
      'rule'    => 'isUnique',
      'message' => 'This username has already been taken.'
    ),
    'password' => array(
      'passrule1' => array(
        'rule' => 'alphaNumeric',
        'message' => 'Only alphaNumeric characters.'
      )
    ),
    'userlevel' => array(
      'rule' => array('range', 0, 3),
      'message' => 'Only values 1 (Admin) or 2 (SuperAdmin) are allowed'
    )
  );
  
  function beforeSave($options = array()) {
        $this->data['User']['password'] = AuthComponent::password($this->data['User']['password']);
        return true;
    }
    
}
?>